clear all;clc
addpath(genpath('.'));  %添加工具箱路径

xyloObj = VideoReader('./Video_data/5_1080.mp4');
% frame = read(xyloObj,67); % first frame only 获取第一帧
Frame_num=xyloObj.NumFrames;
fps = xyloObj.FrameRate;
out = VideoWriter('./Video_stego/Test_DCT_marked');%默认avi封装格式
out.FrameRate = fps;
open(out);
PSNR=[];
SSIM=[];
for f=1:Frame_num
    Cover=readFrame(xyloObj);
    SS=Cover;
    block_size=8;
    [row,col]=size(Cover(:,:,1));w=fix(row/block_size);h=fix(col/block_size);
    emd_zoom=imcrop(Cover,[1 1 h*block_size-1 w*block_size-1]);
    XX=rgb2ycbcr(emd_zoom);XXX=double(XX(:,:,1));
    Stego_Y=blockproc(XXX,[block_size block_size],@DCT_synchronization);
    S=cat(3,Stego_Y,XX(:,:,2),XX(:,:,3));
    Stego=ycbcr2rgb(S);
    ps=find_psnr(Stego_Y,XXX);
    ss=find_ssim(Stego_Y,XXX);
    PSNR=[PSNR;ps];
    SSIM=[SSIM;ss];
    SS(1:w*block_size,1:h*block_size,:)=Stego;
    writeVideo(out,SS);
    disp(['DCT同步',num2str(f),'帧']);
end
close(out);